package com.naiterui.ehp.bs.doctor.dao.impl;

import com.naiterui.ehp.bp.domain.DrAccountOperateLog;
import com.naiterui.ehp.bs.doctor.dao.IDrAccountOperateLogDao;
import com.naiterui.ehp.bs.doctor.repository.IDrAccountOperateLogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 王泽浩
 * @since 1.0.0
 */
@Repository
public class AdDrAccountOperateLogDaoImpl  implements IDrAccountOperateLogDao {

    @Autowired
    private IDrAccountOperateLogRepository drAccountOperateLogRepository;

    @Override
    public void save(DrAccountOperateLog operateLog) {
        drAccountOperateLogRepository.save(operateLog);
    }

    @Override
    public DrAccountOperateLog getLastRejected(long doctorId) {
        List<DrAccountOperateLog> list = drAccountOperateLogRepository.findByDoctorIdOrderByCreatedAtDesc(doctorId);
        if (list.isEmpty()) {
            return null;
        }

        return list.get(0);
    }

}
